﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace ElingOA6_Admin_DSJCJ.BLL
{
    /// <summary>
    /// 业务逻辑ChkInfoCls简要说明。
    /// </summary>
    public class ChkInfoCls
    {
        /// <summary>
        /// 定义DAL.ChkInfoCls的变量
        /// </summary>
        private readonly DAL.ChkInfoCls dal = new DAL.ChkInfoCls();
        /// <summary>
        /// 构造函数
        /// </summary>
        public ChkInfoCls()
        { }

        /// <summary>
        /// 获得数据列表
        /// <creator>chenly</creator>
        /// <date>2013-7-27</date>
        /// </summary>
        /// <param name="strWhere">查询条件</param>
        /// <returns>GetList</returns>
        public DataSet GetList(string strWhere)
        {
            return dal.GetList(strWhere);
        }

                /// <summary>
        /// 获取所有的年份
        /// <creator>zhongyl</creator>
        /// <date>2013-10-16</date>
        /// </summary>
        /// <param name="strEntityNo"></param>
        /// <returns></returns>
        public DataSet GetYeat(string strEntityNo)
        {
            return dal.GetYeat(strEntityNo);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        /// <creator>chenly</creator>
        /// <date>2013-7-26</date>
        /// <param name="fYear">年度</param>
        /// <param name="fInfoClsNo">栏目编号</param>
        /// <param name="fEntityNo">公司编号</param>
        public void Delete(decimal fYear, string fInfoClsNo, string fEntityNo)
        {
            dal.Delete(fYear, fInfoClsNo, fEntityNo);
        }
        /// <summary>
        /// 判断是否存在
        ///  <creator>chenly</creator>
        /// <date>2013-7-26</date>
        /// </summary>
        /// <param name="fYear">年度</param>
        /// <param name="fPreInfoClsNo">上级栏目编号</param>
        /// <param name="fEntityNo">公司编号</param>
        /// <returns>是否存在</returns>
        public bool Exists(decimal fYear, string fInfoClsNo, string fEntityNo)
        {
            return dal.Exists(fYear, fInfoClsNo, fEntityNo);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        /// <param name="model">model对象</param>
        public void Update(Model.ChkInfoCls model)
        {
            dal.Update(model);
        }

        /// <summary>
        /// 得到一个实体对象
        /// </summary>
        ///  <creator>chenly</creator>
        /// <date>2013-7-27</date>
        /// <param name="fYear">年度</param>
        /// <param name="fInfoClsNo">上级栏目编号</param>
        /// <param name="fEntityNo">公司编号</param>
        /// <returns>GetModel</returns>
        public Model.ChkInfoCls GetModel(decimal fYear, string fInfoClsNo, string fEntityNo)
        {
            return dal.GetModel(fYear, fInfoClsNo, fEntityNo);
        }

        /// <summary>
        /// 增加一条数据
        /// </summary>
        /// <param name="model">一个Model对象</param>
        public void Add(Model.ChkInfoCls model)
        {
            dal.Add(model);
        }


        /// <summary>
        ///  获得数据列表
        /// <creator>chenly</creator>
        /// <date>2013-7-26</date>
        /// </summary>
        /// <param name="dt">表</param>
        /// <returns>DataTable</returns>
        public List<Model.ChkInfoCls> DataTableToListChkInfoCls(DataTable dt)
        {
            List<Model.ChkInfoCls> modelList = new List<Model.ChkInfoCls>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                Model.ChkInfoCls model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Model.ChkInfoCls();

                    if (dt.Rows[n]["FYear"].ToString() != "")
                    {
                        model.FYear = decimal.Parse(dt.Rows[n]["FYear"].ToString());
                    }
                    model.FInfoClsNo = dt.Rows[n]["FInfoClsNo"].ToString();
                    model.FPreInfoClsNo = dt.Rows[n]["FPreInfoClsNo"].ToString();
                    model.FInfoClsName = dt.Rows[n]["FInfoClsName"].ToString();
                    if (dt.Rows[n]["FStdScore"].ToString() != "")
                    {
                        model.FStdScore = decimal.Parse(dt.Rows[n]["FStdScore"].ToString());
                    }

                    model.FChkType = dt.Rows[n]["FChkType"].ToString();
                    model.FEntityNo = dt.Rows[n]["FEntityNo"].ToString();
                    model.FisExamine = dt.Rows[n]["FisExamine"].ToString();
                    modelList.Add(model);
                }
            }
            return modelList;
        }

        /// <summary>
        /// 获得数据列表
        /// <creator>sunlj</creator>
        /// <date>2013-10-16</date>
        /// </summary>
        /// <param name="strEntityNo">单位编号</param>
        /// <param name="decYear">年度</param>
        /// <returns></returns>
        public List<Model.ChkInfoCls> GetListByYear(string strEntityNo, decimal decYear)
        {
            DataSet ds = dal.GetListByYear(strEntityNo, decYear);
            return DataTableToListChkInfoCls(ds.Tables[0]);
        }

    }
}
